/**
 * 标准的树上ICG问题，计算SG函数即可
 */
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using vi = vector<int>;


int N, Root;
vector<vi> G;

int dp(int u, int p){
    vi flag(G[u].size(), 0);
    for(auto v : G[u]){
        if(v == p) continue;
        
        int t = dp(v, u);
        if(t < flag.size()) flag[t] = 1;
    }
    int k = 0;
    while(flag[k]) ++k;
    return k;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase; cin >> nofkase;
    for(int kase=1;kase<=nofkase;++kase){
        cin >> N >> Root;
        G.assign(N + 1, {});
        for(int a,b,i=1;i<N;++i){
            cin >> a >> b;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        cout << (dp(Root, 0) ? "Gen" : "Dui") << endl;
    }
    return 0;
}